<?php
// +----------------------------------------------------------------------
// | makePHP 
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://makephp.org All rights reserved.
// +----------------------------------------------------------------------
// | Licensed BSD.(http://www.make.org/BSD-license.txt)
// +----------------------------------------------------------------------
// | Author: 叁石(sanshi) <sanshi0815@tom.com>
// | Author: 白家昌<baijc2004cn@126.com>
// +----------------------------------------------------------------------

/**     
 * base class
 * @version		1.0.0
 * @author			sanshi
 */
class sessionFartory
{
	function __construct()
	{
		$this->sessionFartory();
	}
	function sessionFartory()
	{
	}
	function set($module_name="")
	{
		//设置session的有效时间
		//$maxLife = get_cfg_var('session.gc_maxlifetime') ? get_cfg_var('session.gc_maxlifetime') : 1440;
		if($module_name=="mysql")
		{
			$this->setSessionObject($module_name);
		}else if($module_name=="memcache"){
			$this->setSessionObject($module_name);
		}else{
		}
	}
	function setSessionObject($module_name)
	{
		//设置sesion模块的名字
		//session_module_name(__CLASS__);
		$objectName = "{$module_name}Session";
		//通过工厂类取得
		$sesionObject = Factory::getBaseClass($objectName);
		//设置执行的方法
		session_set_save_handler
		(
			array (& $sesionObject, "__open"), 
			array (& $sesionObject, "__close"),
			array (& $sesionObject, "__read"),
			array (& $sesionObject, "__write"),
			array (& $sesionObject, "__destroy"),
			array (& $sesionObject, "__gc")
		);
	}

}
?>